#include "Game.h"
#include "State.h"

//Feeds the state machine a new state. DON'T USE TO CHANGE STATES!!!
void Game::setState(State* newState)
{
	//Updates currState by giving it the new state.
	currState = newState;
	//Enters the new state.
	currState->Enter();
}

//This gracefully changes states. Use this one.
void Game::changeState(State* newState)
{
	//Exit the state we are running right now.
	currState->Exit();
	//Change over to the new state.
	currState = newState;
	//Start the new state.
	currState->Enter();
}

//Executes states. Bang, bang.
void Game::update()
{
	//Checks for a state in currState. If currState == 0, then condition is false. If currState != 0, then condition is true.
	if(currState)
	{
		//Executes the state, and gives the state access to functions in the state machine.
		currState->Execute(this);
	}
}